package com.fengpb.friday.conductor.core;

public class WorkflowContext {

    public static final ThreadLocal<WorkflowContext> threadLocal = InheritableThreadLocal.withInitial(() -> new WorkflowContext("", ""));

    private String clientApp;

    private String userName;

    public WorkflowContext(String clientApp){
        this.clientApp = clientApp;
        this.userName = null;
    }

    public WorkflowContext(String clientApp, String userName){
        this.clientApp = clientApp;
        this.userName = userName;
    }
    public static WorkflowContext get(){
        return threadLocal.get();
    }

    public static void set(WorkflowContext ctx){
        threadLocal.set(ctx);
    }

    public static void unset(){
        threadLocal.remove();
    }

    /**
     * @return the clientApp
     */
    public String getClientApp() {
        return clientApp;
    }

    /**
     * @return the username
     */
    public String getUserName() {
        return userName;
    }
}
